package com.example.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.web.entity.Enums;
import com.example.web.tools.dto.*;
import com.example.web.tools.dto.SelectResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;

@RestController()
@RequestMapping("/Select")
public class SelectController {

    /**
     * 角色枚举接口
     */
    @RequestMapping(value = "/RoleType", method = RequestMethod.POST)
    public PagedResult<SelectResult> RoleType() throws InvocationTargetException, IllegalAccessException {

       var rs=Arrays.stream(Enums.RoleType.values()).map(n->new SelectResult(n.toString(),n.name(),Integer.toString(n.index()),"")).toList();
       return PagedResult.GetInstance(rs,rs.stream().count());
    }

    /**
     * 订单状态枚举接口
     */
    @RequestMapping(value = "/OrderStatus", method = RequestMethod.POST)
    public PagedResult<SelectResult> OrderStatus() throws InvocationTargetException, IllegalAccessException {

        var rs=Arrays.stream(Enums.OrderStatus.values()).map(n->new SelectResult(n.toString(),n.name(),Integer.toString(n.index()),"")).toList();
        return PagedResult.GetInstance(rs,rs.stream().count());
    }
    /**
     * 审核状态枚举接口
     */
    @RequestMapping(value = "/AuditStatus", method = RequestMethod.POST)
    public PagedResult<SelectResult> AuditStatus() throws InvocationTargetException, IllegalAccessException {

        var rs=Arrays.stream(Enums.AuditStatus.values()).map(n->new SelectResult(n.toString(),n.name(),Integer.toString(n.index()),"")).toList();
        return PagedResult.GetInstance(rs,rs.stream().count());
    }
  
}
